package cn.caishen.report.common.utils;

import java.util.Objects;

/**
 * @author LB
 */
public class IntegerUtil {

    /**
     * 判断参数是否为空
     *
     * @param param
     * @return
     */
    public static boolean isEmpty(Integer param) {
        return Objects.isNull(param) || param <= 0;
    }

    public static boolean isEmpty(Double param) {
        return Objects.isNull(param) || param <= 0;
    }

    /**
     * 判断参数是否不为空
     *
     * @param param
     * @return
     */
    public static boolean isNotEmpty(Integer param) {
        return !isEmpty(param);
    }

    public static boolean isNotEmpty(Double param) {
        return !isEmpty(param);
    }

    /**
     * 相加
     *
     * @param first
     * @param second
     * @return
     */
    public static Integer add(Integer first, Integer second) {
        if (Objects.isNull(first)) {
            first = 0;
        }

        if (Objects.isNull(second)) {
            second = 0;
        }

        return first + second;
    }

    /**
     * 相减
     *
     * @param first
     * @param second
     * @return
     */
    public static Integer subtract(Integer first, Integer second) {
        if (Objects.isNull(first)) {
            first = 0;
        }

        if (Objects.isNull(second)) {
            second = 0;
        }

        return first - second;
    }

    /**
     * 乘
     *
     * @param first
     * @param second
     * @return
     */
    public static Integer multiply(Integer first, Integer second) {
        if (Objects.isNull(first)) {
            return 0;
        }

        if (Objects.isNull(second)) {
            return 0;
        }

        return first * second;
    }

    /**
     * 除
     *
     * @param first
     * @param second
     * @return
     */
    public static Integer divide(Integer first, Integer second) {
        if (Objects.isNull(first)) {
            return 0;
        }

        if (Objects.isNull(second)) {
            return 0;
        }

        return first / second;
    }

    /**
     * 余数
     *
     * @param first
     * @param second
     * @return
     */
    public static Integer remainder(Integer first, Integer second) {
        if (Objects.isNull(first)) {
            return 0;
        }

        if (Objects.isNull(second)) {
            return 0;
        }

        return first % second;
    }

}
